<?php
include_once 'Login/databaseconnection.php';
$q=$_GET['q'];
$hint='';
$ele=explode("_",$q);
$Access_Type=$ele[1];
$NIC_Number=$ele[2];
$Stage=$ele[3];
$L_Set_No=$ele[4];
if($Stage=="back")
{
$Set_No=$L_Set_No-1;
}
else if($Stage=="next")
{
$Set_No=$L_Set_No+1;
}
else if($Stage=="start")
{
$Set_No=1;
}
$Photo="";
$key="Delete photo by_".$Access_Type."_".$User_Name;
$hint=$hint.'<div id="modal"><div id="heading">Are you sure you want to do that?<a href="index.php" class="del_photo_empty red close">Exit</a></div><div id="photos_link">';
$hint=$hint."<input type='hidden' name='set_num' id='set_num' value='$Set_No'/>";
$all_photos=mysql_query("SELECT * FROM photos");
if($all_photos)
{
if(mysql_num_rows($all_photos)>7)
{
if(mysql_num_rows($all_photos)>9)
{
if($Set_No>1)
{
$hint=$hint."<input type='button' class='previousbutton' name='$key' id='back' onClick='get_photo_to_delete(this.name,this.id)'/>&nbsp;";
}
}
if($Access_Type=="Administrator")
{
if(mysql_num_rows($all_photos)>9)
{
if(mysql_num_rows($all_photos)>($Set_No-1)*9+9)
{
$hint=$hint."<input type='button' class='nextbutton' name='$key' id='next' onClick='get_photo_to_delete(this.name,this.id)'/><br/>";
}
while($row_pho=mysql_fetch_array($all_photos))
{
if(empty($Photo))
{
$Photo=$row_pho['Photo'];
}
else
{
$Photo=$Photo.",".$row_pho['Photo'];
}
}
$Photos=explode(",",$Photo);
for($ph=($Set_No-1)*9;$ph<count($Photos)&&$ph<($Set_No-1)*9+9;$ph++)
{
$image=$Photos[$ph];
$image_path="img/".$Photos[$ph];
$hint=$hint."<input type='submit' onclick='ImgDeleteVerification(this.id)' class='del_photo green close' id='$image' style='background-image:url(".$image_path.");background-position:50% 50%;background-repeat:no-repeat;' value=''/>";
}
}
else
{
while($row_pho=mysql_fetch_array($all_photos))
{
$image=$row_pho['Photo'];
$image_path="img/".$image;
$hint=$hint."<input type='submit' onclick='ImgDeleteVerification(this.id)' class='del_photo green close' id='$image' style='background-image:url(".$image_path.");background-position:50% 50%;background-repeat:no-repeat;' value=''/>";}
}
}
else if($Access_Type=="Teacher in Charge")
{
$own_school=mysql_query("SELECT * FROM teacher WHERE T_NIC_Number='$NIC_Number'");
if($own_school)
{
if($row_sch=mysql_fetch_array($own_school))
{
$Own_School_Id=$row_sch['School_Id'];
$all_tea=mysql_query("SELECT * FROM teacher WHERE School_Id='$Own_School_Id'");
if($all_tea)
{
while($row_tea=mysql_fetch_array($all_tea))
{
if(empty($NICs))
{
$NICs='"'.$row_tea['T_NIC_Number'].'"';
}
else
{
$NICs=$NICs.',"'.$row_tea['T_NIC_Number'].'"';
}
}
}
$all_possible_photos=mysql_query("SELECT * FROM photos Added_By in (".$NICs.")");
if(mysql_num_rows($all_possible_photos)>9)
{
if(mysql_num_rows($all_possible_photos)>($Set_No-1)*9+9)
{
$hint=$hint."<input type='button' class='nextbutton' name='$key' id='next' onClick='get_photo_to_delete(this.name,this.id)'/><br/>";
}
while($row_possible_pho=mysql_fetch_array($all_possible_photos))
{
if(empty($Photo))
{
$Photo=$row_possible_pho['Photo'];
}
else
{
$Photo=$Photo.",".$row_possible_pho['Photo'];
}
}
$Photos=explode(",",$Photo);
for($ph=($Set_No-1)*9;$ph<count($Photos)&&$ph<($Set_No-1)*9+9;$ph++)
{
$image=$Photos[$ph];
$image_path="img/".$Photos[$ph];
$hint=$hint."<input type='submit' onclick='ImgDeleteVerification(this.id)' class='del_photo green close' id='$image' style='background-image:url(".$image_path.");background-position:50% 50%;background-repeat:no-repeat;' value=''/>";
}
}
else
{
while($row_possible_pho=mysql_fetch_array($all_possible_photos))
{
$image=$row_pho['Photo'];
$image_path="img/".$image;
$hint=$hint."<input type='submit' onclick='ImgDeleteVerification(this.id)' class='del_photo green close' id='$image' style='background-image:url(".$image_path.");background-position:50% 50%;background-repeat:no-repeat;' value=''/>";
}
}
}
}
else
{
$hint='<div id="modal_empty"><div id="heading_empty">Are you sure you want to do that?<a href="index.php" class="del_photo_empty red close">Exit</a><a href="index.php" class="del_photo_empty red close">Exit</a></div><div id="photos_link_empty">';
$hint=$hint.'<img src="images/alert.jpg" width="12" height="12"/><font color="red">Please insert a photo,then only you can delete!</font>';
}
}
else
{
$all_possible_photos=mysql_query("SELECT * FROM photos Added_By='$NIC_Number'");
if(mysql_num_rows($all_possible_photos)>9)
{
if(mysql_num_rows($all_possible_photos)>($Set_No-1)*9+9)
{
$hint=$hint."<input type='button' class='nextbutton' name='$key' id='next' onClick='get_photo_to_delete(this.name,this.id)'/><br/>";
}
while($row_possible_pho=mysql_fetch_array($all_possible_photos))
{
if(empty($Photo))
{
$Photo=$row_possible_pho['Photo'];
}
else
{
$Photo=$Photo.",".$row_possible_pho['Photo'];
}
}
$Photos=explode(",",$Photo);
for($ph=($Set_No-1)*9;$ph<count($Photos)&&$ph<($Set_No-1)*9+9;$ph++)
{
$image=$Photos[$ph];
$image_path="img/".$Photos[$ph];
$hint=$hint."<input type='submit' onclick='ImgDeleteVerification(this.id)' class='del_photo green close' id='$image' style='background-image:url(".$image_path.");background-position:50% 50%;background-repeat:no-repeat;' value=''/>";
}
}
else
{
while($row_possible_pho=mysql_fetch_array($all_possible_photos))
{
$image=$row_pho['Photo'];
$image_path="img/".$image;
$hint=$hint."<input type='submit' onclick='ImgDeleteVerification(this.id)' class='del_photo green close' id='$image' style='background-image:url(".$image_path.");background-position:50% 50%;background-repeat:no-repeat;' value=''/>";}
}
}
}
else
{
$hint='<div id="modal_empty"><div id="heading_empty">Are you sure you want to do that?<a href="index.php" class="del_photo_empty red close">Exit</a></div><div id="photos_link_empty">';
$hint=$hint.'<img src="images/alert.jpg" width="12" height="12"/><font color="red">Please insert a photo,then only you can delete!</font>';
}
}
$hint=$hint.'</div></div>';
if($hint=="")
{
$response='<div id="modal_empty"><div id="heading_empty">Are you sure you want to do that?<a href="index.php" class="del_photo_empty red close">Exit</a></div><div id="photos_link_empty">';
$response=$response.'<img src="images/alert.jpg" width="12" height="12"/><font color="red">Sorry there are no results for you!</font></div></div>';
}
else
{
$response=$hint;
}
echo $response;
?>